<template>
  <div class="photoinfo-container">
    <!-- 大标题 -->
    <h3 class="title">{{ photoinfo.title }}</h3>
    <!-- 子标题 -->
    <p class="subtitle">
      <span>发表时间：{{ photoinfo.add_time | dateFormat }}</span>
      <span>点击：{{ photoinfo.click }}次</span>
    </p>
    <hr />
    <!-- 图片缩略表区域 -->
    <!-- <div class="thumbs">
      <vue-preview :slides="slide1"></vue-preview>
    </div> -->
    <div>
      <vue-preview
        :list="list"
        :thumbImageStyle="{ width: '100px', height: '100px', margin: '10px' }"
        :previewBoxStyle="{ border: '1px  #999' }"
        :tapToClose="true"
      />
    </div>
    <!-- 内容区域 -->
    <div class="content" v-html="photoinfo.content"></div>

    <!-- 评论区域 -->
    <comment-box :id="this.id"></comment-box>
  </div>
</template>
<script>
import { Toast } from "mint-ui";

//1.导入子组件
import comment from "../subcomponents/comment.vue";
export default {
  data() {
    return {
      id: this.$route.params.id, //将url传过来的id挂载到data的id中，方便以后调用
      photoinfo: [],
      list: []
    };
  },
  created() {
    this.getphotoinfo();
    this.getImgs();
  },
  methods: {
    getphotoinfo() {
      this.$http.get("api/getimageInfo/" + this.id).then(result => {
        if (result.body.status === 0) {
          this.photoinfo = result.body.message[0];
        } else {
          Toast("图片信息获取失败");
        }
      });
    },
    getImgs() {
      this.$http.get("api/getthumimages/" + this.id).then(result => {
        if (result.body.status === 0) {
          result.body.message.forEach((item, i) => {
            item.h = 400;
            item.w = 600;
          });
          this.list = result.body.message;
        }
      });
    }
  },
  components: {
    //用来注册子组件的节点
    "comment-box": comment
  }
};
</script>
<style lang="scss" scoped>
.photoinfo-container {
  padding: 3px;

  .title {
    font-size: 15px;
    text-align: center;
    margin: 15px 0;
    color: #26a2ff;
  }
  .subtitle {
    font-size: 13px;
    display: flex;
    justify-content: space-between;
  }
}
.content {
  font-size: 13px;
  line-height: 30px;
}
</style>